package com.itheima.Demo01.Tesk02.Test01;

import java.util.Comparator;
import java.util.TreeSet;

public class classTest {
    public static void main(String[] args) {
        TreeSet<Employee> set = new TreeSet<>(new Comparator<Employee>() {
            @Override
            public int compare(Employee o1, Employee o2) {
                int i =  o2.getSalary()-o1.getSalary();
                int i1 = i == 0 ? o1.getAge() - o2.getAge():i;
                int i2 =i1==0 ? o1.getName().compareTo(o2.getName()):i1;
                return i2;
            }
        });
        Employee e1 = new Employee("xiongda" ,20,7000);
        Employee e2 = new Employee("gouer" ,30,7000);
        Employee e3 = new Employee("zhamgsan" ,30,7000);
        Employee e4 = new Employee("lisi" ,35,7000);
        Employee e5 = new Employee("wangwu" ,27,8000);
        set.add(e1);
        set.add(e2);
        set.add(e3);
        set.add(e4);
        set.add(e5);
        for (Employee employee : set) {
            System.out.println(employee);

        }

    }
}
